package com.deep.test

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.mllib.linalg.{Vector, Vectors}
import org.apache.spark.mllib.stat.{MultivariateStatisticalSummary, Statistics}

/**
 * @author sw
 * @create 2023-06-02 14:03
 */
object Test06 {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local").setAppName("ALS")
    val sc = new SparkContext(conf)
    sc.setLogLevel("WARN")

    val observations = sc.textFile("data/iris.data").map(_.split(",")).map(p => Vectors.dense(p(0).toDouble, p(1).toDouble, p(2).toDouble, p(3).toDouble))
    val summary: MultivariateStatisticalSummary = Statistics.colStats(observations)
    println(summary.count)
    println(summary.mean)
    println(summary.variance)
    println(summary.max)
    println(summary.min)
    println(summary.normL1)
    println(summary.normL2)
    println(summary.numNonzeros)
  }
}
